/* 
  protected 类中的属性默认修饰，在任意位置都能访问修改
  private 为私有属性只能在当前类中访问或修改，其它类继承也不能访问或修改
  protected 继承
*/
class Person {
  private _name: string
  constructor(name: string) {
    this._name = name
  }
  get name(): string {
    return this._name
  }

  set name(v: string) {
    if (v.length < 10) {
      this._name = v
    }
  }
}

let p: Person = new Person("cg")
console.log("p.name", p.name)

class Animal {
  protected name: string
  constructor(name: string) {
    this.name = name
  }
}

class Dog extends Animal {
  age: number
  constructor(name: string, age: number) {
    super(name)
    this.age = age
  }
  say() {
    console.log("动物名字", this.name)
  }
}

let d: Dog = new Dog("旺财", 10)
d?.say()

export { }